# 3.13 Fan/Motor Module ## 3.13.1 Overview The motor adopts HR1124S motor control chip that is a single channel H-bridge driver chip used in DC motors. The H-bridge drive uses PMOS and NMOS power tubes with low on-resistance, ensuring lower power loss and longer safe working time. In addition, its standby and static working current are both low, so it is commonly used in toys. ## 3.13.2 Schematic Diagram ![6-13](./media/6-13-2.png) **Motor control logic table:** | IO18 | IO17 | motor state | | :--: | :--: | :-------------------: | | HIGH | LOW | forward rotate | | LOW | HIGH | reverse rotate | | HIGH | HIGH | stop (a gradual stop) | | LOW | LOW | brake (a brake stop) | ## 3.13.3 Code Blocks ![6-13](./media/j44.png) This block controls the rotation of the motor. You only need to set motor pins and output levels of the pins. ## 3.13.4 Test Code ### 3.13.4.1 Build Code There are two ways to upload the code: directly open the code file we provide; or manually build blocks. **Directly open the code file we provide:** 1. Click ![](./media/j68.png) and choose `Load from your computer` ![](./media/j67.png) 2. We have already downloaded the codes on computer desktop, so open the file and choose `3-13-fan.sb3` **Manually build blocks:** 1. In ![events](./media/events.png), find ![j1](./media/j1.png) block. 2. In ![control](./media/control.png), find and place ![j2](./media/j2.png) block under ![j1](./media/j1.png). ![6-1-4-1-1](./media/6-1-4-1-1.png) 3. In ![motor](./media/motor.png), put ![6-13](./media/j44.png) into ![j2](./media/j2.png), and set pin IO17 to output `LOW` and pin IO18 to output `HIGH`. 4. Add a delay of 2S. ![6-13](./media/6-13-4-1-1.png) 5. Duplicate the above code and modify pin IO17 to `HIGH` and IO18 to `LOW`. 6. Duplicate again and set both IO17 and IO18 to `LOW`. **Complete Test Code** ![6-13](./media/6-13-4-1-2.png) ### 3.13.4.2 Test Result After uploading code, you will see the fan forward rotates for 2s and then reverses for another 2s. Then it stops. These actions repeat.